﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace KPIS.GERP.GHRMS.APP.Classes
{
	public static class Caption
	{
		private static string FileName
		{
			get
			{
				return HttpContext.Current.Request.Path;
			}
		}

		public static string Get(string paramName)
		{
			if (String.IsNullOrEmpty(paramName)) return "";

			if (!File.Exists(FileName)) return "";

			StreamReader file = null;

			try
			{
				string line = "";
				file = new StreamReader(FileName);
				while ((line = file.ReadLine()) != null)
				{
					var arrayParamWithValues = line.Split('=');
					if (!line.StartsWith("#") && arrayParamWithValues.Count() >= 2 &&
						arrayParamWithValues[0].Trim() == paramName)
					{
						return line.Substring(line.IndexOf("=", StringComparison.Ordinal));
					}
				}
			}
			finally
			{
				if (file != null)
					file.Close();

			}

			return "";
		}
	}
}